<template>
	<view >
		<cu-custom bgColor="bg-cyan">
			<block slot="content">text文本编辑</block>
		</cu-custom>
		<!-- 顶部区域 -->
		<view class="smart-page-head">
			<view class="smart-page-head-title">
				text文本组件
			</view>
		</view>
		<view class="smart-padding-wrap">
			<view class="text-box" scroll-y="true">
				<text>{{text}}</text>
			</view>
			<button type="primary" @click="add">add line</button>
			<button type="warn">remove line</button>
		</view>
		
		
	</view>
</template>

<script>
	export default{
		data(){
			return {
				  texts: [
				    'HBuilder，500万开发者选择的IDE',
				    'MUI，轻巧、漂亮的前端开源框架',
				    'wap2app，M站快速转换原生体验的App',
				    '5+Runtime，为HTML5插上原生的翅膀',
				    'HBuilderX，轻巧、极速，极客编辑器',
				    'uni-app，终极跨平台方案',
				    'HBuilder，500万开发者选择的IDE',
				    'MUI，轻巧、漂亮的前端开源框架',
				    'wap2app，M站快速转换原生体验的App',
				    '5+Runtime，为HTML5插上原生的翅膀',
				    'HBuilderX，轻巧、极速，极客编辑器',
				    'uni-app，终极跨平台方案',
				    '......'
				            ],
				text:"",
				canAdd: true,
				canRemove: false,
				extraLine: []
			};
		},
		methods:{
			add(e){
				// this.extraLine.length代表当前数据个数 充当texts的索引
				this.extraLine.push(this.texts[this.extraLine.length%12]);
				// 用换行符拼接字符串
				this.text = this.extraLine.join('\n');
				this.canAdd = this.extraLine.length<12;
				this.canRemove = this.extraLine.length>0;
			}
		}
		
	}
</script>

<style>
</style>